home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / coolstuf / mcb.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-07-21  |  2.6 KB  |  114 lines

  1. program mcb ;
  2.  
  3.     uses dos,crt ;
  4.  
  5.     type tblchar = array [1..16] of char ;
  6.          str4 = string [4] ;
  7.          str2 = string [2] ;
  8.  
  9.     const hextbl : array [0..15] of char = '0123456789ABCDEF' ;
  10.  
  11.     var p : ^tblchar ;
  12.         regs : registers ;
  13.         fin , psp : boolean ;
  14.         valp : word ;
  15.  
  16. function dec2hex (a : word) : str4 ;
  17.  
  18.     var s : str4 ;
  19.  
  20. begin
  21.     s [0] := chr (4) ;
  22.     s [1] := hextbl [hi (a) shr 4] ;
  23.     s [2] := hextbl [hi (a) and $0F] ;
  24.     s [3] := hextbl [lo (a) shr 4] ;
  25.     s [4] := hextbl [lo (a) and $0F] ;
  26.     dec2hex := s ;
  27. end ;
  28.  
  29. function char2hex (var c : char) : str2 ;
  30.  
  31.     var s : str2 ;
  32.  
  33. begin
  34.     s [0] := chr (2) ;
  35.     s [1] := hextbl [ord (c) shr 4] ;
  36.     s [2] := hextbl [ord (c) and $0F] ;
  37.     char2hex := s ;
  38. end ;
  39.  
  40. procedure showp ;
  41.  
  42.     var i : byte ;
  43.  
  44. begin
  45.     write (' ',p^[1],'  ') ; { 'M' or 'Z' }
  46.     asm mov ax,word ptr p+2
  47.         mov es,ax
  48.         mov ax,word ptr es:1
  49.         mov valp,ax
  50.     end ;
  51.     write (valp:5,' ') ;
  52.     asm mov ax,word ptr p+2
  53.         mov es,ax
  54.         mov ax,word ptr es:3
  55.         mov valp,ax
  56.     end ;
  57.     write (valp:5,'  ') ;
  58.  
  59.     for i := 6 to 16 do
  60.         write (char2hex (p^[i]),' ') ;
  61.  
  62.     for i := 6 to 16 do
  63.         if p^[i] <= ' ' then
  64.             write ('¿')
  65.         else
  66.             write (p^[i]) ;
  67.  
  68.     asm mov ax,word ptr p+2
  69.         mov valp,ax
  70.     end ;
  71.     write ('  0x',dec2hex (valp),' ') ;
  72.  
  73.     psp := false ;
  74.     asm mov ax,word ptr p+2
  75.         inc ax
  76.         mov es,ax
  77.         cmp word ptr es:0,$20CD { debut d'un PSP }
  78.         jne @notPSP
  79.         mov byte ptr psp,1 {true}
  80. @notPSP:
  81.     end ;
  82.     if psp then
  83.         write ('  ok') ;
  84.     writeln ;
  85. end ;
  86.  
  87. begin
  88.     asm mov ah,$52
  89.         int $21
  90.         mov ax,es
  91.         dec ax
  92.         mov es,ax {es=es-1}
  93. {        mov ax,es:[bx+12]
  94.         mov word ptr p,ax } { l'offset = 0 !!! }
  95.         mov ax,es:[bx+14]
  96.         mov word ptr p+2,ax
  97.     end ;
  98.     fin := false ;
  99.     writeln ('MZ|PSPowner|Para|     Data not documented (Name of prog)     |Segment|PSPfollow?') ;
  100.     repeat
  101.         showp ;
  102.         if p^[1] = 'Z' then
  103.             fin := true ;
  104.         if not fin then
  105.             asm mov ax,word ptr p+2
  106.                 mov es,ax
  107.                 inc ax
  108.                 add ax,es:3
  109.                 mov word ptr p+2,ax
  110.             end ;
  111.     until fin ;
  112.     write (#13,#10,'PSPowner = 0 mean MCB free, PSPowner = 8 mean allocated by DOS, else PSPowner = ') ; 
  113.     write ('segment of the PSP owner for this MCB ... 1 Para = 16 byte !!! ... Coded by Sam') ;
  114. end.